package com.example.h9iserver.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 *
 * @author yupi
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public Result<?> businessExceptionHandler(BusinessException e) {
        log.error("businessException: " + e.getMessage(), e);
        return new Result<>(ExceptionCodeConstants.ERROR, e.errorMessage);
    }
//    @ExceptionHandler(Exception.class)
//    public Result<?> ExceptionHandler(Exception e) {
//        log.error("businessException: " + e.getMessage(), e);
//        return new Result<>(ExceptionCodeConstants.ERROR, e.getMessage());
//    }
}
